package com.aaa.service.impl;

import com.aaa.dao.StaffDao;
import com.aaa.dao.impl.StaffDaoImpl;
import com.aaa.entity.Staff;
import com.aaa.service.StaffService;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

public class StaffServiceImpl implements StaffService {
    private StaffDao staffDao = new StaffDaoImpl();

    @Override
    public Staff login(String staffId, String password) {



        return staffDao.login(staffId,password);
    }

    @Override
    public int updateStaffByStaffId(Staff staff) {

        return staffDao.updateStaffByStaffId(staff);
    }

    @Override
    public int addStaffByStaffId(Staff staff) {

        return staffDao.addStaffByStaffId(staff);
    }


    @Override
    public int deleteStaffByStaffId(int staffId) {
        return staffDao.deleteStaffByStaffId(staffId);
    }

    @Override
    public Map<String,Object>  findAllStaff(Integer pageNumber, Integer pageSize, String searchId, String searchName) {
        int count = getAllStaffInfoCount(searchId,searchName);
        List<Staff> list = staffDao.findAllStaff(pageNumber,pageSize,searchId,searchName);
        Map<String,Object> map = new HashMap<>();
        map.put("count",count);
        map.put("list",list);
        return map ;
    }





    @Override
    public int getAllStaffInfoCount(String searchId, String searchName) {
        return staffDao.getAllStaffInfoCount(searchId,searchName);
    }

    @Override
    public List<Staff> getMaxStaffId() {
        return staffDao.getMaxStaffId();
    }

    @Override
    public int updatePassword(String password, int staffId) {
        return staffDao.updatePassword(password,staffId);
    }
}
